<style lang="less">
</style>

<template>
  <div>
    <Card>
      <iview-table
              ref="table"
              :baseURL="queryModel.baseURL"
              :menuId="dataModel.menuId"
              :columns="dataModel.columns"
              :order="dataModel.order"
              :pageNumber="pageModel.pageNumber"
              :pageSize="pageModel.pageSize"
              :defaultFilters="queryModel.defaultFilters"
              v-on="{changeTotalSize:changeTotalSize,changeSelect:changeSelect}">
      </iview-table>
      <br>
      <iview-page
              :totalSize="pageModel.totalSize"
              :pageNumber="pageModel.pageNumber"
              :pageSize="pageModel.pageSize"
              :pageSizeOpts="pageModel.pageSizeOpts"
              v-on="{changePageNumber:changePageNumber,changePageSize:changePageSize}">
      </iview-page>
    </Card>
  </div>
</template>

<script>
    import iviewTable from '@/view/common/table/Table.vue';
    import iviewPage from '@/view/common/page/Page.vue';
    export default {
        components: {
            iviewTable,
            iviewPage
        },
        data () {
            return {
                selectRows: [],
                queryModel: {
                    // 网关代理路径(必须)+资源路径(可选)
                    baseURL: '/user/outbound/record'
                },
                dataModel: {
                    menuId: 1000,
                    columns: [
                        {
                            title: '出库时间',
                            key: 'creationTime',
                            render: (h, params) => {
                                return h('span', this.$moment(params.row.creationTime).format('YYYY年MM月DD日'))
                            }
                        },
                        {
                            title: '出库商品',
                            key: 'itemName'
                        },{
                            title: '入库类型',
                            key: 'typeName'
                        },{
                            title: '入库数量',
                            key: 'quantity'
                        },{
                            title: '商品形态',
                            key: 'normalFlag'
                        },{
                            title: '入库备注',
                            key: 'remark'
                        }
                    ],
                    order: 'id desc'
                },
                pageModel: {
                    totalSize: 0,
                    pageNumber: 1,
                    pageSize: 10,
                    pageSizeOpts: [10, 50, 100, 500]
                }
            };
        },
        methods: {
            changeSelect (rows) {
                this.selectRows = rows
            },
            changeTotalSize (totalSize) {
                this.pageModel.totalSize = totalSize
            },
            changePageNumber (pageNumber) {
                this.pageModel.pageNumber = pageNumber
            },
            changePageSize (pageSize) {
                this.pageModel.pageSize = pageSize
            },
            refresh () {
                this.$refs.table.refresh()
            },
            init () {
                this.refresh()
            }
        },
        mounted () {
            this.init()
        },
        watch: {
            '$route' (to) {
                if (to.path === '/store/record/outbound') {
                    this.init()
                }
            }
        }
    }
</script>

<style>

</style>
